/*
 * @Author: your name
 * @Date: 2020-08-24 21:03:32
 * @LastEditTime: 2020-08-26 21:09:27
 * @LastEditors: Please set LastEditors
 * @Description: In User Settings Edit
 * @FilePath: \examlist\src\store\addType\index.js
 */
import { getType, delType, addType } from '../../api/type'
import { Message } from 'view-design'

const state = {
  data: []
}

const mutations = {
  getList(state, payload) {
    state.data = payload
  }
}
const actions = {
  async get({ commit }) {
    const { data: res } = await getType()
    commit('getList', res.data)
  },
  async delete({ commit }, action) {
    const { data: res } = await delType(action)
    // console.log(state.data)
    if (res.code === 1) {
      Message.success(res.msg)
    }
  },
  async add({ commit }, action) {
    const { data: res } = await addType(action)
    if (res.code === 1) {
      Message.success(res.msg)
    }
  }
}
export default {
  namespaced: true,
  state,
  mutations,
  actions
}
